const Base = require('../base.js');
const tencentcloud = require("tencentcloud-sdk-nodejs")
var config = {
  sdkappid: '1400046691',
  appkey: '69e8f1574cc92cb690bfa63a8d39a05c'
}
// 发送短信
module.exports = class extends Base {
  async indexAction() {
    const smsClient = tencentcloud.sms.v20210111.Client
    const client = new smsClient({
      credential: {
        secretId: "AKID97qLcfl0JL8fy3uWv62jGZeU5S5WalbC",
        secretKey: "VCgv1sUs11mKdhX8VeicHitqZ5PVMzOY",
      },
      region: "ap-guangzhou",
      profile: {
        signMethod: "HmacSHA256",
        httpProfile: {
          reqMethod: "POST",
          reqTimeout: 30,
          endpoint: "sms.tencentcloudapi.com"
        },
      },
    })
    const params = {
      SmsSdkAppId: config.sdkappid,
      SignName: "独行工匠工作室", // 签名的名称
      TemplateId: "1670911", // 正文模板id
      TemplateParamSet: [this.get("msg")], // {1}变量的值
      PhoneNumberSet: ["+86" + this.get("phone")],// 接收的手机号码
    }
    client.SendSms(params, (err, response) => {
      if (err) {
        console.log(err)
        this.error(err)
        return
      }
      this.success('发送成功')
    })
    this.success('发送成功')
  }
}




